<template>
  <div>
    <table style="width: 100%;">
      <tr style="height: 100%;border: black 1px solid" v-for="i in data" :key='i.id'>
        <td style="width: 100%">
          <p>申请人： {{i.name}}</p>
         <p v-show="i.refuse!=null">拒绝原因： {{i.refuse}}</p>
         <p>审批状态:{{i.start}}</p>
          <p v-for='(j,k,index) in i.info' :key="index">{{k}}: {{j}}</p>
          <select v-model="sp">
            <option :value="1">通过</option>
            <option :value="2">拒绝</option>
          </select>
          <textarea v-show="sp==2" v-model="refuse">

          </textarea>
          <button @click="tj(i.id)">提交</button>
        </td>
      </tr>
    </table>

  </div>
</template>

<script>
import moment from 'moment';
import 'moment/locale/zh-cn';
// import mycate from "./diguizhanshi_zi";

export default {
  name: "gongdanlx",
  data() {
    return {
      data: [],
      sp: 0,
      refuse: null
    }
  },
  // components:{
  //   mycate
  // },
  methods: {
    get_all(){
      this.$axios.post('http://127.0.0.1:8000/qingjiainfo/',{
        'pid': +sessionStorage.getItem('uid')
      })
      .then(resp=>{
        this.data = resp.data
        console.log(this.data)
      })
    },
    tj(id){
      if(this.sp!=2){
        this.refuse= null
      }

      this.$axios.put('http://127.0.0.1:8000/qingjiainfo/',{
        'id': id,
        'start': this.sp,
        'refuse': this.refuse
      })
        .then(resp=>{
          alert(resp.data.msg)
        })
    }
  },
  mounted() {
    this.get_all()
  }
}
</script>

<style scoped>

</style>